/** * @Description: 未签约页面 * @author Administrator */

<template>
	<view class="u-wrap">
		<u-row>
			<template v-if="menus">
				<u-col span="3">
					<!-- 左侧导航栏 -->
					<left-menu :exptxt="exptxt" @selectCurrent="selectCurrent($event)"></left-menu>
				</u-col>

				<u-col span="9">
					<!-- 右侧菜单列表 -->
					<right-menu :selectExptxt="selectExptxt" :menus="menus" :enterprise="enterprise"></right-menu>
				</u-col>
			</template>

			<view class="center" v-else>
				<image style="width: 120rpx; height: 120rpx;" class="img" src="https://cdn.uviewui.com/uview/template/taobao-order.png" mode=""></image>
				<view class="explain">
					<view class="tips">暂无菜单~</view>
				</view>
			</view>
		</u-row>
		
		<wyb-loading ref="loading"/>
	</view>
</template>

<script>
	import * as api from '@/api/apiList/home.js';
	import {
		formDate
	} from '@/utils/formDate.js';


	import leftMenu from './components/leftMenu';
	import rightMenu from './components/rightMenu/rightMenu.vue';

	export default {
		components: {
			leftMenu, //左侧菜单
			rightMenu, //右侧菜单
		},
		data(){
			return{
				menus: "", //菜单数据
				enterprise: "", //企业数据
				exptxt: "", //套餐列表
				current: 0, //当前选中项
				selectExptxt:""
			}
		},
		watch:{
			current:{
				async handler(val){
					
					this.$nextTick(()=>{
						this.$refs.loading.showLoading() // 显示
					})
					let res = await this.API_list()
					
					
					if(res.data.data.menus.length){
						this.menus = res.data.data.menus[0] //菜单数据
						this.enterprise = res.data.data.enterprise //企业数据
						this.exptxt = JSON.parse(this.menus.exptxt) //套餐列表
						this.selectExptxt = this.exptxt[val]//选中套餐
					}
					// console.log(this.selectExptxt)
					
					this.$refs.loading.hideLoading() // 隐藏
				},
				immediate:true,
			}
		},
		methods:{
			async API_list(day = formDate(new Date())) { //获取菜单接口
				let result = {
					param: {
						day //日期 格式：yyyy-MM-dd
					}
				};
				return await api.list(result);
			},
			async getList(){//获取列表
				this.$nextTick(()=>{
					this.$refs.loading.showLoading() // 显示
				})
				let res = await this.API_list()
				
				
				if(res.data.data.menus.length){
					this.menus = res.data.data.menus[0] //菜单数据
					this.enterprise = res.data.data.enterprise //企业数据
					this.exptxt = JSON.parse(this.menus.exptxt) //套餐列表
					this.selectExptxt = this.exptxt[this.current]//选中套餐
				}
				console.log(this.menus)
				
				this.$refs.loading.hideLoading() // 隐藏
			},
			selectCurrent(current){
				this.current = current
			}
		}
	};
</script>

<style lang="scss" scoped>
	.center{
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		.img{
			width: 30rpx;
			height: 30rpx;
		}
	}
	.u-wrap {
		

		.center {
			text-align: center;
			margin: 200rpx auto;
			font-size: 32rpx;

			image {
				width: 164rpx;
				height: 164rpx;
				border-radius: 50%;
				margin-bottom: 20rpx;
			}

			.tips {
				font-size: 24rpx;
				color: #999999;
				margin-top: 20rpx;
			}
		}
	}

	.u-row {
		/deep/.u-col-3 {
			padding: 0;
		}
	}

	.lunchOrDinner {
		height: 70rpx;
		line-height: 70rpx;
		text-align: center;
		font-size: 32rpx;
		font-weight: 600;
		letter-spacing: 2px;
		margin-bottom: 5rpx;
		color: #ffffff;
		background-color: #f43a3d;
	}
</style>
